package com.drought.rained.presenter;

import com.drought.rained.BuildConfig;
import com.drought.rained.business.CustomConsumerLJ;
import com.drought.rained.business.ParamsFactoryLJ;
import com.drought.rained.cache.UserInfoLJ;
import com.drought.rained.mvpview.RolloveMvpViewLJ;
import com.drought.rained.response.RolloveResponseLJ;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.functions.Consumer;

public class RollovePresenterLJ extends BasePresenterLJ {
    private RolloveMvpViewLJ mvpView;

    public RollovePresenterLJ(RolloveMvpViewLJ mvpView) {
        this.mvpView = mvpView;
    }

    public void getApplyData(String orderId) {
        Map<String, Object> fromMap = new HashMap<>();
        fromMap.put("orderId", orderId);
        toSubScribe(req.getRolloverOrder(BuildConfig.channel, UserInfoLJ.getToken(), ParamsFactoryLJ.getCommonParams(fromMap)), new CustomConsumerLJ<RolloveResponseLJ>() {
            @Override
            public void call(RolloveResponseLJ updateResponse) {
                mvpView.onGetDataNext(updateResponse);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                mvpView.onGetDataError(throwable);
            }
        });
    }

}
